package com.wgo.bpot.server.persist.hibernate;

import static javax.persistence.TemporalType.TIMESTAMP;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Temporal;

import com.wgo.bpot.server.persist.UniqueValue;


@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class UniqueValueEjb implements UniqueValue {
	private long dbId;
	private String entityType;
	private long nextValue;
	private Date lastUpdated;
	
	
	@Id
	public long getDbId() {
		return dbId;
	}
	
    public void setDbId(long dbId) {
		this.dbId = dbId;
	}

	/* (non-Javadoc)
	 * @see remato.server.ejb.UniqueValue#getLastUpdated()
	 */
	@Temporal(TIMESTAMP)	
	public Date getLastUpdated() {
		return lastUpdated;
	}
	
	/* (non-Javadoc)
	 * @see remato.server.ejb.UniqueValue#setLastUpdated(java.util.Date)
	 */
	public void setLastUpdated(Date lastUpdated) {
		this.lastUpdated = lastUpdated;
	}
	/* (non-Javadoc)
	 * @see remato.server.ejb.UniqueValue#getEntityType()
	 */
	public String getEntityType() {
		return entityType;
	}
	/* (non-Javadoc)
	 * @see remato.server.ejb.UniqueValue#setEntityType(java.lang.String)
	 */
	public void setEntityType(String entityType) {
		this.entityType = entityType;
	}

	/* (non-Javadoc)
	 * @see remato.server.ejb.UniqueValue#getNextValue()
	 */
	public long getNextValue() {
		return nextValue;
	}
	/* (non-Javadoc)
	 * @see remato.server.ejb.UniqueValue#setNextValue(long)
	 */
	public void setNextValue(long nextValue) {
		this.nextValue = nextValue;
	}
	
	/**
	 * Needed to trigger CGLib proxy (ie. if other CGLib-proxies is used as 
	 * parameter.)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		return super.equals(obj);
	}

}
